package com.lengxf.pay.starter.parent.transfer;

import cn.hutool.core.lang.Assert;
import com.lengxf.pay.common.service.BasePayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TransferService {

    private final List<ResultTransfer> transferList;


    public TransferService(@Autowired(required = false) List<ResultTransfer> transferList) {
        Assert.notEmpty(transferList);
        this.transferList = transferList;
    }

    public ResultTransfer get(BasePayService basePayService) {
        return transferList.stream()
                .filter(e -> e.payType().equals(basePayService.getClass()))
                .findFirst()
                .orElseThrow(() -> new RuntimeException("未找到对应数据转换器"));
    }


}
